var host='http://weixin.aitshow.com';
var token = getCookie('token');
var commonHeader = { // 公共header
	// "Accept": "application/json",
	// "Authorization": "Bear " + "...",
	// contentType: "application/json;charset=UTF-8",
	token:token
};
// 1c97557bd3fe5ac955451e341a1eb7d9
//获取cookie
function getCookie(name) {
	//web中cookie是以分号+空格隔开的
	var res = document.cookie.split('; ');
	for (let i = 0; i < res.length; i++)
		if (res[i].split('=')[0] === name) return res[i].split('=')[1];
		//未找到
	return '';
}
//请求方法
function ajaxGet(url, params, successfn, errorfn) {
    $.ajax({
        type: 'GET',
        url:host +'/'+ url,
        data:params,
		contentType: "application/json;charset=UTF-8",
		// headers: commonHeader,
        dataType:'json',
        // async:false,
        // cache:true,
		success: function(res) {
			successfn(res);
		},
		error: function(res) {
			errorfn(res);
		}
    });
};
//请求方法
function ajaxPost(url, params, successfn, errorfn) {
    $.ajax({
        type: 'POST',
        url:host +'/'+ url,
        data:params,
		contentType: "application/json;charset=UTF-8",
		// headers: commonHeader,
        dataType:'json',
        // async:false,
        // cache:true,
        success: function(res) {
        	successfn(res);
        },
        error: function(res) {
        	errorfn(res);
        }
    });
};
